import random
random_number = random.randint(1,100)
number = int(input("猜数字 between 1 and 100: "))
gold = 5000
while gold > 0:
    if number > random_number:
        print("大了")
        gold -= 500
    elif number < random_number :
        print("小了")
        gold -= 500
    else :
        print("恭喜猜中，本轮幸运数字：{},你剩余的gold:{}".format(random_number, gold + 3000))
        a = int(input("是否继续游戏？1.继续游戏 2.退出游戏"))
        if a == 1:
            random_number1 = random.randint(1,100)
            number = int(input("猜数字 between 1 and 100: "))
            while gold > 0:
                if number > random_number1:
                    print("大了")
                    gold -= 500
                elif number < random_number1:
                    print("小了")
                    gold -= 500
                else:
                    print("恭喜猜中，本轮幸运数字：{},你剩余的gold:{}".format(random_number1, gold + 3000))
                    break
                number = int(input("猜数字 between 1 and 100: "))
            else:
                print("金币余额不足,游戏退出")
        else :
            break
        break
    number = int(input("猜数字 between 1 and 100: "))
else:
    print("金币余额不足,游戏退出")